package org.lyl.taobao.controller;

import org.lyl.taobao.api.IOrderService;
import org.lyl.taobao.service.OrderServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: Re
 * @Date: 2021/4/11 9:47
 */
@WebServlet("/deleteOrder")
public class DeleteOrderServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Integer orderId = Integer.parseInt(req.getParameter("cancel"));
        IOrderService iOrderService = new OrderServiceImpl();
        if (iOrderService.deleteOrder(orderId)) {
            req.setAttribute("msg","订单取消成功");
        } else {
            req.setAttribute("msg","订单取消失败");
        }
        req.getRequestDispatcher("checkOrder.jsp").forward(req,resp);
    }
}
